<template>
	<view class="login-container">
		<u-button type="primary" class="btn" @click="login('teacher')">教师登录</u-button>
		<u-button type="warning" class="btn" @click="login('student')">学生登录</u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		methods: {
			login(role) {
				try {
					uni.setStorageSync('role', role)
					uni.showLoading({
						title: '正在登录...',
					})
					setTimeout(() => {
						uni.switchTab({
							url: '/pages/index/' + role
						})
					}, 1000)
				} catch (e) {
					//TODO handle the exception
				}
			}
		}
	}
</script>

<style lang="scss">
	.login-container {
		padding: 20% 30px 30px;

		.btn {
			display: block;
			margin: 10px 30px
		}
	}
</style>
